<?php

namespace apps\common\controllers;

use mix\facades\Request;
use mix\http\Controller;

class AdminController extends Controller
{
    public function __construct()
    {
//        app()->response->format = \mix\http\Response::FORMAT_JSON;

    }

    /**成功返回
     * @param string $msg 消息
     * @param array $data 数据
     * @param int $code code
     * @return string
     */
    public function success($msg = '成功', $url = '', $data = array(), $code = 200)
    {
        $result = array(
            'msg' => $msg,
            'url' => $url,
            'data' => $data,
            'code' => $code,
        );
        /*if (Request::isPost()){

        }*/
        return json_encode($result);
    }

    

    /**失败返回
     * @param string $msg 消息
     * @param array $data 数据
     * @param int url $url
     * @return string
     */
    public function error($msg = '失败', $url = 403, $data = array(),$code=403)
    {
        $result = array(
            'url' => $url,
            'msg' => $msg,
            'data' => $data,
            'code' => $code,
        );
        return json_encode($result);
    }


}
